/**
 * 维修记录详情对话框（可用于添加和修改对话框）
 */
var modifyInfoDlg = {
    data: {
        modifyId: "",
        modifyNote: "",
        modifyDate: ""
    }
};
var modify = {
    layerIndex: -1,
    condition: {
        modifyNote: "",
        modifyDate: ""
    }
};

/**
 * 表单验证
 * @returns {*}
 */
modifyInfoDlg.validateForm = function () {
    return true;
};
modifyInfoDlg.close = function () {
    parent.layer.close(window.parent.modify.layerIndex);
};

/**
 * 点击维修记录按钮
 */
modify.openModifyCar = function () {
    this.layerIndex = layer.open({
    type: 2,
    title: '添加维修记录',
    area: ['500px', '300px'],
    fix: false,
    maxmin: true,
    content: Feng.ctxPath + '/modify/modify_add'
    });
};

/**
 * 提交维修记录详情
 */
modifyInfoDlg.addSubmit = function () {

    var ajax = new $ax(Feng.ctxPath + "/modify/add", function (data) {
        window.parent.Feng.success("添加成功!");
        modifyInfoDlg.close();
    }, function (data) {
        window.parent.Feng.error("添加失败!" + data.responseJSON.message + "!");
    });
    ajax.set(this.data);
    ajax.start();
};


$(function () {
    //获取车辆信息
    var ajax = new $ax(Feng.ctxPath + "/modify/getModifyInfo?modifyId=" + Feng.getUrlParam("modifyId"));
    var result = ajax.start();
    modifyInfoDlg.data = result.data;
    modifyInfoDlg.app = new Vue({
        el: '#modifyForm',
        data: modifyInfoDlg.data,
        methods: {
            submitForm: function (e) {
                e.preventDefault();
            },
            ensure: function () {
                var result = modifyInfoDlg.validateForm();
                if (result === true) {
                    modifyInfoDlg.editSubmit();
                } else {
                    Feng.alert(result);
                }
            }
        }
    });
});